package com.lw.function;

import java.util.function.Predicate;

/**
 * @author Administrator
 * @version 1.0
 * @description:
 * @date 2022/4/25 22:30
 */
public class TestPredicate {
    public static void main(String[] args) {
        Predicate<String> predicate1=s->s!=null;

        System.err.println(predicate1.test("zhangsan"));

        System.err.println(predicate1.test(null));

        Predicate<String> predicate2=s->s !="";

        System.err.println(predicate1.and(predicate2).test(" "));

        Predicate<String> predicate3=s->!s.trim().equals("");

        System.err.println(predicate3.test(" "));

        System.err.println(predicate1.and(predicate2).and(predicate3).test(" "));

        System.err.println(predicate1.and(predicate2).and(predicate3).test(null));

        //和正常写代码一样，会出现空指针异常
        //predicate3.and(predicate2).and(predicate1).test(null);

        System.err.println(predicate1.negate().test(""));

        System.err.println(Predicate.isEqual("12345").test("12345"));
    }
}
